/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.era7bioinformatics.aws.s3.components.beta1

//  to impl
import com.era7bioinformatics.aws.s3.components.generic._
import com.era7bioinformatics.aws.s3.components.generic.Object
import com.era7bioinformatics.aws.s3.components.generic.data._

import com.era7bioinformatics.common._
import com.era7bioinformatics.aws.components.AwsDate
import com.era7bioinformatics.aws.components.AwsBinary

class ObjectImpl(theBucket: Bucket,
                 theACL: ACL,
                 theKey: String,
                 theDate: AwsDate,
                 theValue: AwsBinary,
                 theMetadata: ObjectMetadata) extends Entity with Object {

  override val bucket: Bucket = theBucket

  private[this] var currentACL: ACL = theACL
  override def acl: ACL = currentACL

  override val key = theKey
  
  val date: AwsDate = theDate

  //  critical to set this as lazy; it could ve defined as a def up in the trait
  lazy val value: AwsBinary = theValue

  override lazy val versions: Seq[ObjectVersion] = Seq()

  lazy val metadata: ObjectMetadata = theMetadata
  
}


object ObjectImpl {

  def apply(bucket: Bucket,
            acl: ACL,
            key: String,
            date: AwsDate,
            value: AwsBinary, 
            metadata: ObjectMetadata): Object = new ObjectImpl(theBucket = bucket, theACL = acl, theDate = date, theKey = key, theValue = value, theMetadata= metadata)


  

}
